package com.alex.amqp.service;

import com.alex.amqp.bean.Book;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class BookService {

    @RabbitListener(queues = {"atguigu.news"})
    public void receive(Book book) {
        System.out.println(Thread.currentThread().getName() + ": atguigu.news 收到消息: " + book);
    }

    @RabbitListener(queues = {"atguigu.emps"})
    public void receive2(Book book) {
        System.out.println(Thread.currentThread().getName() + ": atguigu.emps 收到消息: " + book);
    }

    @RabbitListener(queues = {"atguigu"})
    public void receiveMessage(Message message) {
        System.out.println(message.getBody());
        System.out.println(message.getMessageProperties());
    }
}
